package ee.logsimulator.data;

import java.awt.Color;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public enum Clazz {

  WARRIOR("Warrior", 199, 156, 110),
  DRUID("Druid", 255, 125, 10),
  PALADIN("Paladin", 245, 140, 186),
  SHAMAN("Shaman", 0, 112, 222),
  DEATH_KNIGHT("DeathKnight", 196, 30, 59),
  ROGUE("Rogue", 255, 245, 105),
  HUNTER("Hunter", 171, 212, 115),
  MAGE("Mage", 105, 204, 240),
  WARLOCK("Warlock", 148, 130, 201),
  PRIEST("Priest", 255, 255, 255),
  FRIENDLY("friendly", 255, 255, 255),
  UNKNOWN("Unknown", 255, 255, 255),
  VEHICLE("Vehicle", 255, 255, 255);

  private static final Map<String, Clazz> m;
  private String name;
  private Color color;

  static {
    HashMap<String, Clazz> map = new HashMap<String, Clazz>();
    for (Clazz cl : values()) {
      map.put(cl.getName(), cl);
    }
    m = Collections.unmodifiableMap(map);
  }

  private Clazz(String name, int r, int g, int b) {
    this.name = name;
    color = new Color(r, g, b);
  }

  public Color getColor() {
    return color;
  }

  public String getName() {
    return name;
  }

  public boolean isPlayer() {
    switch (this) {
    case UNKNOWN:
    case FRIENDLY:
    case VEHICLE:
      return false;
    default:
      return true;
    }
  }

  public static Clazz fromName(String name) {
    Clazz cl = m.get(name);
    if (cl == null) {
			return UNKNOWN;
    }
    return cl;
  }
}
